package com.ruoyi.accountant.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Balance {
    private Long bid;
    private Long ofAccount;
    private Integer ofCurrency;
    private BigDecimal balance;
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createtime;

    private Currency ofCurrencyObject; // 余额所属币种

    public void add(BigDecimal value) {
        this.balance = this.balance.add(value);
    }

    public void subtract(BigDecimal value) {
        this.balance = this.balance.subtract(value);
    }
}